package com.mitaotao._1_语法._3_分支._3_if判断;

import java.util.Scanner;

public class _04_计算器 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数字：");
        double num1 = scanner.nextDouble();
        System.out.println("请输入第二个数字：");
        double num2 = scanner.nextDouble();
        System.out.println("请输入需要计算的符号：");
        String operator = scanner.next();
        double result = 0 ;

        switch (operator){
            case "+":
                result = num1 + num2;
                break;
            case "-":
                result = num1 - num2;
                break;
            case "*":
                result = num1 * num2;
                break;
            case "/":
                result = num1 / num2;
                break;
        }
        System.out.println("计算结果为："+result);
        scanner.close();
    }
}
